class MyThread extends Thread{
    @Override
    public void run() {
        //这里的run方法,就是该线程要完成的工作
        while (true){
            System.out.println("hello thread");

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }


        }

    }
}
public class demo01 {
    public static void main(String[] args) throws InterruptedException {
        Thread t =new MyThread();
        t.start();
        //t.run();
        //此处没有创建出新的线程,就是在主线程中执行run中的循环打印
    while (true){
        System.out.println("hello main");
        Thread.sleep(1000);
    }
    }
}
